"""洗衣机工作流程"""
class washmachine:
    def __init__(self,brand,capacity):
        """洗衣机初始化函数

        Args:
            brand (_type_):品牌
            capacity (_type_): 容量
        """
        self.brand = brand
        self.capacity = capacity
        #门状态
        self.is_close = False
        #模式 0关闭 1轻 2重
        self.mode = 0
        #转速
        self.motor = 0
        
    def open(self):
        self.is_close = False
        print("打开洗衣机门")
    def close(self):
        self.is_close = True
        print("关闭洗衣机门")
        
    def set_mode(self,new_mode):
        if new_mode not in [1,2]:
            print("模式设置错误")
            return
        self.mode = new_mode
        
    def set_motor(self,speed):
        self.motor = speed
    
    def wash(self):
        if not self.is_close:
            print("请关门")
            return
        if self.mode == 0:
            print("请设置洗衣模式")
            return
        print("放水")
        if self.mode == 1:
            print("轻模式")
            self.set_motor(1000)
            print("马达转速：",self.motor)
        if self.mode == 2:
            print("重模式")
            self.set_motor(2000)
            print("马达转速",self.motor)
            
#创建对象
xi = washmachine("海尔",10)
xi.open()
xi.close()
xi.set_mode(1)
xi.wash()
            
